#!/bin/bash

rootfs_dir=/home/pbb3/qemu-busybox-test/rootfs-xfce
cross_tool_path=/usr/arm-linux-gnueabihf

Iinclude_dir+=" -I$cross_tool_path/include -I$rootfs_dir/include"
Iinclude_dir+=" -I$rootfs_dir/include/glib-2.0"
Iinclude_dir+=" -I$rootfs_dir/lib/glib-2.0/include"
Iinclude_dir+=" -I$rootfs_dir/include/glib-2.0/gio"
Iinclude_dir+=" -I$rootfs_dir/include/glib-2.0/glib"
Iinclude_dir+=" -I$rootfs_dir/include/glib-2.0/gobject"
Iinclude_dir+=" -I$rootfs_dir/include/gio-unix-2.0"
Iinclude_dir+=" -I$rootfs_dir/include/xfce4/libxfce4util"

Llibs_dir+=" -L$cross_tool_path/lib -L$rootfs_dir/lib"
Llibs_dir+=" -L$rootfs_dir/lib/glib-2.0 "
# Llibs_dir+=" -lexpat"
# Llibs_dir+=" -lxfce4util"
Llibs+=" -lffi -lgio-2.0 -lglib-2.0 -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lz"
Llibs+=" -lexpat"
Llibs+=" -lxfce4util"

export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export CC=${CROSS_COMPILE}gcc

export CFLAGS=${Iinclude_dir}
export LDFLAGS=${Llibs_dir}
export LIBS=$Llibs
# LIBS        libraries to pass to the linker, e.g. -l<library>
CPPFLAGS=${Iinclude_dir}
# export CPP=
export CXX=${CROSS_COMPILE}g++
# PKG_CONFIG    path to pkg-config utility
export PKG_CONFIG_PATH=${rootfs_dir}/lib/pkgconfig:${PKG_CONFIG_PATH}
# PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path
export GLIB_CFLAGS=${Iinclude_dir}
export GLIB_LIBS=${Llibs_dir}

export PREFIX=${rootfs_dir}
export EPREFIX=${rootfs_dir}

export LT_SYS_LIBRARY_PATH=$rootfs_dir/lib

#export GDBUS_CODEGEN=$rootfs_dir/bin/gdbus-codegen
export PATH=$rootfs_dir/../glib/bin:$PATH


./configure --host=arm-linux-gnueabihf --prefix=$rootfs_dir
make -j64
make -j64 install

unset CC
unset CFLAGS
unset LDFLAGS
unset LIBS
unset CPPFLAGS
unset CPP
unset PKG_CONFIG
unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
unset GLIB_CFLAGS
unset GLIB_LIBS

